
function registerPageEvents()  {
	Common.addTooltips();
}

Common.addEvent(window, "load", registerPageEvents)



// JavaScript Document
var FeedDeleter = 
{
    confirmDelete : function (htmlNode) 
    {
        var name = Ajax.getText(htmlNode);
        var confMsgCont = document.getElementById("msgCont");
        /*for(var i = 0; i < confMsgCont.childNodes.length; i++) {
                alert(confMsgCont.childNodes[i]);
                confMsgCont.removeChild(confMsgCont.childNodes[i]);
        }*/
        confMsgCont.innerHTML = "";
        var absPos = findPos(htmlNode);
        confMsgCont.style.left = (absPos[0] + 100).toString() + "px";
        confMsgCont.style.top = (absPos[1] - 20).toString() + "px";
        var qTitle = document.createElement("h6");
        qTitle.appendChild(document.createTextNode("Deleting " + htmlNode.innerHTML));
        qTitle.className = "confirmTitle";
        var quest = document.createElement("p");
        quest.appendChild(document.createTextNode("Are you sure?"));
        quest.className = "confirmQuest";
        var confInput = document.createElement("input");
        confInput.type = "button";
        confInput.value = "OK";
        var conFunBody = "FeedDeleter.deleteFeed('" + Ajax.getText(htmlNode) + "')";
        confInput.onclick = new Function("evt", conFunBody);
        var cancelInput = document.createElement("input");
        cancelInput.type = "button";
        cancelInput.value = "Reset";
        var resFunBody = "document.getElementById('msgCont').innerHTML = ''; document.getElementById('msgCont').style.display= 'none';";
        cancelInput.onclick = new Function("evt", resFunBody);
        confMsgCont.appendChild(qTitle);
        confMsgCont.appendChild(quest);
        confMsgCont.appendChild(confInput);
        confMsgCont.appendChild(cancelInput);
        confMsgCont.style.display = "block";
        //alert(absPos[1]);
    },
    deleteFeed : function (htmlNodeTxt) 
    {
        var name = htmlNodeTxt;
        var req = Ajax.createXMLHttpRequest();
        req.onreadystatechange = function () 
        {
            if (req.readyState == 1) { }
            if (req.readyState == 2) { }
            if (req.readyState == 4) {
                if (req.status == 200) {
                    alert("ok");
                }
                if (req.status == 404) {
                    alert("errore");
                }
            }
        }
        var reqUrl = "./cgi-bin/unsubscribe.pl?feed=" + name;
        req.open("get", reqUrl, true);
        req.setRequestHeader("Content-type", "text/plain");
        req.send(null);
    }
};
function findPos(obj) 
{
    var curleft = curtop = 0;
    if (obj.offsetParent) {
        do {
            curleft += obj.offsetLeft;
            curtop += obj.offsetTop;
        }
        while (obj = obj.offsetParent);
    }
    return [curleft, curtop];
}
